package com.laker.admin.module.excel.controller;

import com.laker.admin.framework.aop.Metrics;
import com.laker.admin.framework.model.Response;
import com.laker.admin.module.excel.domain.ExcelFill;
import com.laker.admin.module.excel.entity.ExcelFillCmd;
import com.laker.admin.module.excel.facade.ExcelFillFacade;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * excel模版使用
 * </p>
 *
 * @author nihongxin
 * @since 2021-12-08
 */
@RestController
@RequestMapping("/excelFill")
@Metrics
public class ExcelFillController {

    @Autowired
    private ExcelFillFacade excelFillFacade;

    @PostMapping("/save")
    @ApiOperation(value = "保存数据", tags = "excel模版使用")
    public Response save(@RequestBody ExcelFill excelFill) {
        return excelFillFacade.save(excelFill);
    }

    @ApiOperation(value = "查询模版列表", tags = "excel模版使用")
    @PostMapping(value = "/list")
    public Response list(@RequestBody ExcelFillCmd excelFillCmd) {
        return excelFillFacade.list(excelFillCmd);
    }

    @ApiOperation(value = "获取单个数据", tags = "excel模版使用")
    @GetMapping(value = "/getById/{id}")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", dataType = "Long", required = true, value = "主键id", paramType = "form")
    })
    public Response getById(@PathVariable Long id) {
        return excelFillFacade.getById(id);
    }

    @ApiOperation(value = "根据orderId获取单个数据", tags = "excel模版使用")
    @GetMapping(value = "/getByOrderId")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "orderId", dataType = "String", required = false, value = "orderId", paramType = "form"),
            @ApiImplicitParam(name = "id", dataType = "Long", required = false, value = "id", paramType = "form")
    })
    public Response getByOrderId(String orderId, Long id) {
        return excelFillFacade.getByOrderId(orderId);
    }

    @ApiOperation(value = "删除数据", tags = "excel模版使用")
    @DeleteMapping(value = "/deleteById/{id}")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", dataType = "Long", required = true, value = "主键id", paramType = "form")
    })
    public Response deleteById(@PathVariable Long id) {
        return excelFillFacade.deleteById(id);
    }

}